#!/usr/bin/env ruby

unless (ARGV[1]) then
  puts "usage :\n #{$0} restart_flow.dat output-mach.sol"
  exit 1
end

lines = IO.readlines(ARGV[0])

File.open(ARGV[1],'w') do |f|
  f.puts "MeshVersionFormatted 2"
  f.puts "Dimension 3"
  f.puts "SolAtVertices"
  nnode = lines.size - 1
  printf(" %d nodes\n",nnode)
  f.puts nnode
  f.puts "1 1"
  nnode.times do |i|
    line = lines[i+1]
    col = line.split
    mach = col[12].to_f
    f.printf( " %.18e\n",mach )
  end
end
